﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using F_MODEL;
using System.Data;
using System.Data.SqlClient;

namespace F_DAL
{
  public  class WaybillDal
    {
      /// <summary>
      /// 带货
      /// </summary>
      /// <param name="Trans"></param>
      /// <returns></returns>
      public bool DaiHuo(Waybill Way)
      {
          SqlParameter[] sql ={
                              new  SqlParameter("@waybillId",SqlDbType.VarChar),
                              new  SqlParameter("@origin",SqlDbType.VarChar),
                              new  SqlParameter("@destination",SqlDbType.VarChar),
                              new  SqlParameter("@flightInfo",SqlDbType.VarChar),
                              new  SqlParameter("@originTime",SqlDbType.DateTime),
                              new  SqlParameter("@destinationTime",SqlDbType.DateTime),
                              new  SqlParameter("@proof",SqlDbType.VarChar),
                              new  SqlParameter("@freeSpace",SqlDbType.Decimal),
                              new  SqlParameter("@submitTime",SqlDbType.DateTime),
                              new  SqlParameter("@userId",SqlDbType.Int),
                              new  SqlParameter("@waybillIsDel",SqlDbType.Int),
                              new  SqlParameter("@waybillTimeSpan",SqlDbType.DateTime),
                              new  SqlParameter("@waybillStatue",SqlDbType.Int),
                              };
          sql[0].Value = Way.waybillId;
          sql[1].Value = Way.origin;
          sql[2].Value = Way.destination;
          sql[3].Value = Way.flightInfo;
          sql[4].Value = Way.originTime;
          sql[5].Value = Way.destinationTime;
          sql[6].Value = Way.proof;
          sql[7].Value = Way.freeSpace;
          sql[8].Value = Way.submitTime;
          sql[9].Value = Way.userId;
          sql[10].Value = Way.waybillIsDel;
          sql[11].Value = Way.waybillTimeSpan;
          sql[12].Value = Way.waybillStatue;
          return DbHelperSQL.RunProcedureReturnBool("Waybill_Add", sql);
      }

      public List<Waybill> GetWay(int id)
      {
          string sql = string.Format("select * from Waybill where userId ='{0}'", id);
          return DBhelpers.GetList<Waybill>(sql);
      }
    }
}
